﻿using System;
using System.Data;
using System.Text;
using System.Data.SqlClient;
using DBUtility;//Please add references
namespace DAL
{
	/// <summary>
	/// 数据访问类:Interview
	/// </summary>
	public partial class Interview
	{
		public Interview()
		{}
		#region  Method

		/// <summary>
		/// 得到最大ID
		/// </summary>
		public int GetMaxId()
		{
		return DbHelperSQL.GetMaxID("Id", "Interview"); 
		}

		/// <summary>
		/// 是否存在该记录
		/// </summary>
		public bool Exists(int Id)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select count(1) from Interview");
			strSql.Append(" where Id=@Id");
			SqlParameter[] parameters = {
					new SqlParameter("@Id", SqlDbType.Int,4)
			};
			parameters[0].Value = Id;

			return DbHelperSQL.Exists(strSql.ToString(),parameters);
		}


		/// <summary>
		/// 增加一条数据
		/// </summary>
		public int Add(Model.Interview model)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("insert into Interview(");
			strSql.Append("Name,Sex,Age,Birthday,Nationality,Family,FamilyInfo,FamilyIncomeFrom,FamilyIncome,House,Assets,Cost,CostInfo,AcceptHelpInfo,Honour,StopSchoolingInfo,IsLiveSchool,NeedLiveMoney,Remark,Remark_V,DistrictId,Address,PostalAddress,Demand,Teacher,Principal,School,Grade_Class,PhotoList,InsTime,GoTime,IsDelete,InsertVolunteerId,VolunteerIdStr,AppealId)");
			strSql.Append(" values (");
			strSql.Append("@Name,@Sex,@Age,@Birthday,@Nationality,@Family,@FamilyInfo,@FamilyIncomeFrom,@FamilyIncome,@House,@Assets,@Cost,@CostInfo,@AcceptHelpInfo,@Honour,@StopSchoolingInfo,@IsLiveSchool,@NeedLiveMoney,@Remark,@Remark_V,@DistrictId,@Address,@PostalAddress,@Demand,@Teacher,@Principal,@School,@Grade_Class,@PhotoList,@InsTime,@GoTime,@IsDelete,@InsertVolunteerId,@VolunteerIdStr,@AppealId)");
			strSql.Append(";select @@IDENTITY");
			SqlParameter[] parameters = {
					new SqlParameter("@Name", SqlDbType.NVarChar,50),
					new SqlParameter("@Sex", SqlDbType.NVarChar,5),
					new SqlParameter("@Age", SqlDbType.Int,4),
					new SqlParameter("@Birthday", SqlDbType.DateTime),
					new SqlParameter("@Nationality", SqlDbType.NVarChar,20),
					new SqlParameter("@Family", SqlDbType.NVarChar),
					new SqlParameter("@FamilyInfo", SqlDbType.NVarChar,1000),
					new SqlParameter("@FamilyIncomeFrom", SqlDbType.NVarChar,500),
					new SqlParameter("@FamilyIncome", SqlDbType.NVarChar,500),
					new SqlParameter("@House", SqlDbType.NVarChar,50),
					new SqlParameter("@Assets", SqlDbType.NVarChar,500),
					new SqlParameter("@Cost", SqlDbType.NVarChar,100),
					new SqlParameter("@CostInfo", SqlDbType.NVarChar,150),
					new SqlParameter("@AcceptHelpInfo", SqlDbType.NVarChar,150),
					new SqlParameter("@Honour", SqlDbType.NVarChar,300),
					new SqlParameter("@StopSchoolingInfo", SqlDbType.NVarChar,100),
					new SqlParameter("@IsLiveSchool", SqlDbType.Bit,1),
					new SqlParameter("@NeedLiveMoney", SqlDbType.Bit,1),
					new SqlParameter("@Remark", SqlDbType.NVarChar,200),
					new SqlParameter("@Remark_V", SqlDbType.NVarChar,200),
					new SqlParameter("@DistrictId", SqlDbType.Int,4),
					new SqlParameter("@Address", SqlDbType.NVarChar,50),
					new SqlParameter("@PostalAddress", SqlDbType.NVarChar,100),
					new SqlParameter("@Demand", SqlDbType.NVarChar),
					new SqlParameter("@Teacher", SqlDbType.NVarChar,50),
					new SqlParameter("@Principal", SqlDbType.NVarChar,50),
					new SqlParameter("@School", SqlDbType.NVarChar,30),
					new SqlParameter("@Grade_Class", SqlDbType.NVarChar,30),
					new SqlParameter("@PhotoList", SqlDbType.NVarChar,500),
					new SqlParameter("@InsTime", SqlDbType.DateTime),
					new SqlParameter("@GoTime", SqlDbType.DateTime),
					new SqlParameter("@IsDelete", SqlDbType.Bit,1),
					new SqlParameter("@InsertVolunteerId", SqlDbType.Int,4),
					new SqlParameter("@VolunteerIdStr", SqlDbType.NVarChar),
					new SqlParameter("@AppealId", SqlDbType.Int,4)};
			parameters[0].Value = model.Name;
			parameters[1].Value = model.Sex;
			parameters[2].Value = model.Age;
			parameters[3].Value = model.Birthday;
			parameters[4].Value = model.Nationality;
			parameters[5].Value = model.Family;
			parameters[6].Value = model.FamilyInfo;
			parameters[7].Value = model.FamilyIncomeFrom;
			parameters[8].Value = model.FamilyIncome;
			parameters[9].Value = model.House;
			parameters[10].Value = model.Assets;
			parameters[11].Value = model.Cost;
			parameters[12].Value = model.CostInfo;
			parameters[13].Value = model.AcceptHelpInfo;
			parameters[14].Value = model.Honour;
			parameters[15].Value = model.StopSchoolingInfo;
			parameters[16].Value = model.IsLiveSchool;
			parameters[17].Value = model.NeedLiveMoney;
			parameters[18].Value = model.Remark;
			parameters[19].Value = model.Remark_V;
			parameters[20].Value = model.DistrictId;
			parameters[21].Value = model.Address;
			parameters[22].Value = model.PostalAddress;
			parameters[23].Value = model.Demand;
			parameters[24].Value = model.Teacher;
			parameters[25].Value = model.Principal;
			parameters[26].Value = model.School;
			parameters[27].Value = model.Grade_Class;
			parameters[28].Value = model.PhotoList;
			parameters[29].Value = model.InsTime;
			parameters[30].Value = model.GoTime;
			parameters[31].Value = model.IsDelete;
			parameters[32].Value = model.InsertVolunteerId;
			parameters[33].Value = model.VolunteerIdStr;
			parameters[34].Value = model.AppealId;

			object obj = DbHelperSQL.GetSingle(strSql.ToString(),parameters);
			if (obj == null)
			{
				return 0;
			}
			else
			{
				return Convert.ToInt32(obj);
			}
		}
		/// <summary>
		/// 更新一条数据
		/// </summary>
		public bool Update(Model.Interview model)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("update Interview set ");
			strSql.Append("Name=@Name,");
			strSql.Append("Sex=@Sex,");
			strSql.Append("Age=@Age,");
			strSql.Append("Birthday=@Birthday,");
			strSql.Append("Nationality=@Nationality,");
			strSql.Append("Family=@Family,");
			strSql.Append("FamilyInfo=@FamilyInfo,");
			strSql.Append("FamilyIncomeFrom=@FamilyIncomeFrom,");
			strSql.Append("FamilyIncome=@FamilyIncome,");
			strSql.Append("House=@House,");
			strSql.Append("Assets=@Assets,");
			strSql.Append("Cost=@Cost,");
			strSql.Append("CostInfo=@CostInfo,");
			strSql.Append("AcceptHelpInfo=@AcceptHelpInfo,");
			strSql.Append("Honour=@Honour,");
			strSql.Append("StopSchoolingInfo=@StopSchoolingInfo,");
			strSql.Append("IsLiveSchool=@IsLiveSchool,");
			strSql.Append("NeedLiveMoney=@NeedLiveMoney,");
			strSql.Append("Remark=@Remark,");
			strSql.Append("Remark_V=@Remark_V,");
			strSql.Append("DistrictId=@DistrictId,");
			strSql.Append("Address=@Address,");
			strSql.Append("PostalAddress=@PostalAddress,");
			strSql.Append("Demand=@Demand,");
			strSql.Append("Teacher=@Teacher,");
			strSql.Append("Principal=@Principal,");
			strSql.Append("School=@School,");
			strSql.Append("Grade_Class=@Grade_Class,");
			strSql.Append("PhotoList=@PhotoList,");
			strSql.Append("InsTime=@InsTime,");
			strSql.Append("GoTime=@GoTime,");
			strSql.Append("IsDelete=@IsDelete,");
			strSql.Append("InsertVolunteerId=@InsertVolunteerId,");
			strSql.Append("VolunteerIdStr=@VolunteerIdStr,");
			strSql.Append("AppealId=@AppealId");
			strSql.Append(" where Id=@Id");
			SqlParameter[] parameters = {
					new SqlParameter("@Name", SqlDbType.NVarChar,50),
					new SqlParameter("@Sex", SqlDbType.NVarChar,5),
					new SqlParameter("@Age", SqlDbType.Int,4),
					new SqlParameter("@Birthday", SqlDbType.DateTime),
					new SqlParameter("@Nationality", SqlDbType.NVarChar,20),
					new SqlParameter("@Family", SqlDbType.NVarChar),
					new SqlParameter("@FamilyInfo", SqlDbType.NVarChar,1000),
					new SqlParameter("@FamilyIncomeFrom", SqlDbType.NVarChar,500),
					new SqlParameter("@FamilyIncome", SqlDbType.NVarChar,500),
					new SqlParameter("@House", SqlDbType.NVarChar,50),
					new SqlParameter("@Assets", SqlDbType.NVarChar,500),
					new SqlParameter("@Cost", SqlDbType.NVarChar,100),
					new SqlParameter("@CostInfo", SqlDbType.NVarChar,150),
					new SqlParameter("@AcceptHelpInfo", SqlDbType.NVarChar,150),
					new SqlParameter("@Honour", SqlDbType.NVarChar,300),
					new SqlParameter("@StopSchoolingInfo", SqlDbType.NVarChar,100),
					new SqlParameter("@IsLiveSchool", SqlDbType.Bit,1),
					new SqlParameter("@NeedLiveMoney", SqlDbType.Bit,1),
					new SqlParameter("@Remark", SqlDbType.NVarChar,200),
					new SqlParameter("@Remark_V", SqlDbType.NVarChar,200),
					new SqlParameter("@DistrictId", SqlDbType.Int,4),
					new SqlParameter("@Address", SqlDbType.NVarChar,50),
					new SqlParameter("@PostalAddress", SqlDbType.NVarChar,100),
					new SqlParameter("@Demand", SqlDbType.NVarChar),
					new SqlParameter("@Teacher", SqlDbType.NVarChar,50),
					new SqlParameter("@Principal", SqlDbType.NVarChar,50),
					new SqlParameter("@School", SqlDbType.NVarChar,30),
					new SqlParameter("@Grade_Class", SqlDbType.NVarChar,30),
					new SqlParameter("@PhotoList", SqlDbType.NVarChar,500),
					new SqlParameter("@InsTime", SqlDbType.DateTime),
					new SqlParameter("@GoTime", SqlDbType.DateTime),
					new SqlParameter("@IsDelete", SqlDbType.Bit,1),
					new SqlParameter("@InsertVolunteerId", SqlDbType.Int,4),
					new SqlParameter("@VolunteerIdStr", SqlDbType.NVarChar),
					new SqlParameter("@AppealId", SqlDbType.Int,4),
					new SqlParameter("@Id", SqlDbType.Int,4)};
			parameters[0].Value = model.Name;
			parameters[1].Value = model.Sex;
			parameters[2].Value = model.Age;
			parameters[3].Value = model.Birthday;
			parameters[4].Value = model.Nationality;
			parameters[5].Value = model.Family;
			parameters[6].Value = model.FamilyInfo;
			parameters[7].Value = model.FamilyIncomeFrom;
			parameters[8].Value = model.FamilyIncome;
			parameters[9].Value = model.House;
			parameters[10].Value = model.Assets;
			parameters[11].Value = model.Cost;
			parameters[12].Value = model.CostInfo;
			parameters[13].Value = model.AcceptHelpInfo;
			parameters[14].Value = model.Honour;
			parameters[15].Value = model.StopSchoolingInfo;
			parameters[16].Value = model.IsLiveSchool;
			parameters[17].Value = model.NeedLiveMoney;
			parameters[18].Value = model.Remark;
			parameters[19].Value = model.Remark_V;
			parameters[20].Value = model.DistrictId;
			parameters[21].Value = model.Address;
			parameters[22].Value = model.PostalAddress;
			parameters[23].Value = model.Demand;
			parameters[24].Value = model.Teacher;
			parameters[25].Value = model.Principal;
			parameters[26].Value = model.School;
			parameters[27].Value = model.Grade_Class;
			parameters[28].Value = model.PhotoList;
			parameters[29].Value = model.InsTime;
			parameters[30].Value = model.GoTime;
			parameters[31].Value = model.IsDelete;
			parameters[32].Value = model.InsertVolunteerId;
			parameters[33].Value = model.VolunteerIdStr;
			parameters[34].Value = model.AppealId;
			parameters[35].Value = model.Id;

			int rows=DbHelperSQL.ExecuteSql(strSql.ToString(),parameters);
			if (rows > 0)
			{
				return true;
			}
			else
			{
				return false;
			}
		}

		/// <summary>
		/// 删除一条数据
		/// </summary>
		public bool Delete(int Id)
		{
			
			StringBuilder strSql=new StringBuilder();
			strSql.Append("delete from Interview ");
			strSql.Append(" where Id=@Id");
			SqlParameter[] parameters = {
					new SqlParameter("@Id", SqlDbType.Int,4)
			};
			parameters[0].Value = Id;

			int rows=DbHelperSQL.ExecuteSql(strSql.ToString(),parameters);
			if (rows > 0)
			{
				return true;
			}
			else
			{
				return false;
			}
		}
		/// <summary>
		/// 批量删除数据
		/// </summary>
		public bool DeleteList(string Idlist )
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("delete from Interview ");
			strSql.Append(" where Id in ("+Idlist + ")  ");
			int rows=DbHelperSQL.ExecuteSql(strSql.ToString());
			if (rows > 0)
			{
				return true;
			}
			else
			{
				return false;
			}
		}


		/// <summary>
		/// 得到一个对象实体
		/// </summary>
		public Model.Interview GetModel(int Id)
		{
			
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select  top 1 Id,Name,Sex,Age,Birthday,Nationality,Family,FamilyInfo,FamilyIncomeFrom,FamilyIncome,House,Assets,Cost,CostInfo,AcceptHelpInfo,Honour,StopSchoolingInfo,IsLiveSchool,NeedLiveMoney,Remark,Remark_V,DistrictId,Address,PostalAddress,Demand,Teacher,Principal,School,Grade_Class,PhotoList,InsTime,GoTime,IsDelete,InsertVolunteerId,VolunteerIdStr,AppealId from Interview ");
			strSql.Append(" where Id=@Id");
			SqlParameter[] parameters = {
					new SqlParameter("@Id", SqlDbType.Int,4)
			};
			parameters[0].Value = Id;

			Model.Interview model=new Model.Interview();
			DataSet ds=DbHelperSQL.Query(strSql.ToString(),parameters);
			if(ds.Tables[0].Rows.Count>0)
			{
				if(ds.Tables[0].Rows[0]["Id"]!=null && ds.Tables[0].Rows[0]["Id"].ToString()!="")
				{
					model.Id=int.Parse(ds.Tables[0].Rows[0]["Id"].ToString());
				}
				if(ds.Tables[0].Rows[0]["Name"]!=null && ds.Tables[0].Rows[0]["Name"].ToString()!="")
				{
					model.Name=ds.Tables[0].Rows[0]["Name"].ToString();
				}
				if(ds.Tables[0].Rows[0]["Sex"]!=null && ds.Tables[0].Rows[0]["Sex"].ToString()!="")
				{
					model.Sex=ds.Tables[0].Rows[0]["Sex"].ToString();
				}
				if(ds.Tables[0].Rows[0]["Age"]!=null && ds.Tables[0].Rows[0]["Age"].ToString()!="")
				{
					model.Age=int.Parse(ds.Tables[0].Rows[0]["Age"].ToString());
				}
				if(ds.Tables[0].Rows[0]["Birthday"]!=null && ds.Tables[0].Rows[0]["Birthday"].ToString()!="")
				{
					model.Birthday=DateTime.Parse(ds.Tables[0].Rows[0]["Birthday"].ToString());
				}
				if(ds.Tables[0].Rows[0]["Nationality"]!=null && ds.Tables[0].Rows[0]["Nationality"].ToString()!="")
				{
					model.Nationality=ds.Tables[0].Rows[0]["Nationality"].ToString();
				}
				if(ds.Tables[0].Rows[0]["Family"]!=null && ds.Tables[0].Rows[0]["Family"].ToString()!="")
				{
					model.Family=ds.Tables[0].Rows[0]["Family"].ToString();
				}
				if(ds.Tables[0].Rows[0]["FamilyInfo"]!=null && ds.Tables[0].Rows[0]["FamilyInfo"].ToString()!="")
				{
					model.FamilyInfo=ds.Tables[0].Rows[0]["FamilyInfo"].ToString();
				}
				if(ds.Tables[0].Rows[0]["FamilyIncomeFrom"]!=null && ds.Tables[0].Rows[0]["FamilyIncomeFrom"].ToString()!="")
				{
					model.FamilyIncomeFrom=ds.Tables[0].Rows[0]["FamilyIncomeFrom"].ToString();
				}
				if(ds.Tables[0].Rows[0]["FamilyIncome"]!=null && ds.Tables[0].Rows[0]["FamilyIncome"].ToString()!="")
				{
					model.FamilyIncome=ds.Tables[0].Rows[0]["FamilyIncome"].ToString();
				}
				if(ds.Tables[0].Rows[0]["House"]!=null && ds.Tables[0].Rows[0]["House"].ToString()!="")
				{
					model.House=ds.Tables[0].Rows[0]["House"].ToString();
				}
				if(ds.Tables[0].Rows[0]["Assets"]!=null && ds.Tables[0].Rows[0]["Assets"].ToString()!="")
				{
					model.Assets=ds.Tables[0].Rows[0]["Assets"].ToString();
				}
				if(ds.Tables[0].Rows[0]["Cost"]!=null && ds.Tables[0].Rows[0]["Cost"].ToString()!="")
				{
					model.Cost=ds.Tables[0].Rows[0]["Cost"].ToString();
				}
				if(ds.Tables[0].Rows[0]["CostInfo"]!=null && ds.Tables[0].Rows[0]["CostInfo"].ToString()!="")
				{
					model.CostInfo=ds.Tables[0].Rows[0]["CostInfo"].ToString();
				}
				if(ds.Tables[0].Rows[0]["AcceptHelpInfo"]!=null && ds.Tables[0].Rows[0]["AcceptHelpInfo"].ToString()!="")
				{
					model.AcceptHelpInfo=ds.Tables[0].Rows[0]["AcceptHelpInfo"].ToString();
				}
				if(ds.Tables[0].Rows[0]["Honour"]!=null && ds.Tables[0].Rows[0]["Honour"].ToString()!="")
				{
					model.Honour=ds.Tables[0].Rows[0]["Honour"].ToString();
				}
				if(ds.Tables[0].Rows[0]["StopSchoolingInfo"]!=null && ds.Tables[0].Rows[0]["StopSchoolingInfo"].ToString()!="")
				{
					model.StopSchoolingInfo=ds.Tables[0].Rows[0]["StopSchoolingInfo"].ToString();
				}
				if(ds.Tables[0].Rows[0]["IsLiveSchool"]!=null && ds.Tables[0].Rows[0]["IsLiveSchool"].ToString()!="")
				{
					if((ds.Tables[0].Rows[0]["IsLiveSchool"].ToString()=="1")||(ds.Tables[0].Rows[0]["IsLiveSchool"].ToString().ToLower()=="true"))
					{
						model.IsLiveSchool=true;
					}
					else
					{
						model.IsLiveSchool=false;
					}
				}
				if(ds.Tables[0].Rows[0]["NeedLiveMoney"]!=null && ds.Tables[0].Rows[0]["NeedLiveMoney"].ToString()!="")
				{
					if((ds.Tables[0].Rows[0]["NeedLiveMoney"].ToString()=="1")||(ds.Tables[0].Rows[0]["NeedLiveMoney"].ToString().ToLower()=="true"))
					{
						model.NeedLiveMoney=true;
					}
					else
					{
						model.NeedLiveMoney=false;
					}
				}
				if(ds.Tables[0].Rows[0]["Remark"]!=null && ds.Tables[0].Rows[0]["Remark"].ToString()!="")
				{
					model.Remark=ds.Tables[0].Rows[0]["Remark"].ToString();
				}
				if(ds.Tables[0].Rows[0]["Remark_V"]!=null && ds.Tables[0].Rows[0]["Remark_V"].ToString()!="")
				{
					model.Remark_V=ds.Tables[0].Rows[0]["Remark_V"].ToString();
				}
				if(ds.Tables[0].Rows[0]["DistrictId"]!=null && ds.Tables[0].Rows[0]["DistrictId"].ToString()!="")
				{
					model.DistrictId=int.Parse(ds.Tables[0].Rows[0]["DistrictId"].ToString());
				}
				if(ds.Tables[0].Rows[0]["Address"]!=null && ds.Tables[0].Rows[0]["Address"].ToString()!="")
				{
					model.Address=ds.Tables[0].Rows[0]["Address"].ToString();
				}
				if(ds.Tables[0].Rows[0]["PostalAddress"]!=null && ds.Tables[0].Rows[0]["PostalAddress"].ToString()!="")
				{
					model.PostalAddress=ds.Tables[0].Rows[0]["PostalAddress"].ToString();
				}
				if(ds.Tables[0].Rows[0]["Demand"]!=null && ds.Tables[0].Rows[0]["Demand"].ToString()!="")
				{
					model.Demand=ds.Tables[0].Rows[0]["Demand"].ToString();
				}
				if(ds.Tables[0].Rows[0]["Teacher"]!=null && ds.Tables[0].Rows[0]["Teacher"].ToString()!="")
				{
					model.Teacher=ds.Tables[0].Rows[0]["Teacher"].ToString();
				}
				if(ds.Tables[0].Rows[0]["Principal"]!=null && ds.Tables[0].Rows[0]["Principal"].ToString()!="")
				{
					model.Principal=ds.Tables[0].Rows[0]["Principal"].ToString();
				}
				if(ds.Tables[0].Rows[0]["School"]!=null && ds.Tables[0].Rows[0]["School"].ToString()!="")
				{
					model.School=ds.Tables[0].Rows[0]["School"].ToString();
				}
				if(ds.Tables[0].Rows[0]["Grade_Class"]!=null && ds.Tables[0].Rows[0]["Grade_Class"].ToString()!="")
				{
					model.Grade_Class=ds.Tables[0].Rows[0]["Grade_Class"].ToString();
				}
				if(ds.Tables[0].Rows[0]["PhotoList"]!=null && ds.Tables[0].Rows[0]["PhotoList"].ToString()!="")
				{
					model.PhotoList=ds.Tables[0].Rows[0]["PhotoList"].ToString();
				}
				if(ds.Tables[0].Rows[0]["InsTime"]!=null && ds.Tables[0].Rows[0]["InsTime"].ToString()!="")
				{
					model.InsTime=DateTime.Parse(ds.Tables[0].Rows[0]["InsTime"].ToString());
				}
				if(ds.Tables[0].Rows[0]["GoTime"]!=null && ds.Tables[0].Rows[0]["GoTime"].ToString()!="")
				{
					model.GoTime=DateTime.Parse(ds.Tables[0].Rows[0]["GoTime"].ToString());
				}
				if(ds.Tables[0].Rows[0]["IsDelete"]!=null && ds.Tables[0].Rows[0]["IsDelete"].ToString()!="")
				{
					if((ds.Tables[0].Rows[0]["IsDelete"].ToString()=="1")||(ds.Tables[0].Rows[0]["IsDelete"].ToString().ToLower()=="true"))
					{
						model.IsDelete=true;
					}
					else
					{
						model.IsDelete=false;
					}
				}
				if(ds.Tables[0].Rows[0]["InsertVolunteerId"]!=null && ds.Tables[0].Rows[0]["InsertVolunteerId"].ToString()!="")
				{
					model.InsertVolunteerId=int.Parse(ds.Tables[0].Rows[0]["InsertVolunteerId"].ToString());
				}
				if(ds.Tables[0].Rows[0]["VolunteerIdStr"]!=null && ds.Tables[0].Rows[0]["VolunteerIdStr"].ToString()!="")
				{
					model.VolunteerIdStr=ds.Tables[0].Rows[0]["VolunteerIdStr"].ToString();
				}
				if(ds.Tables[0].Rows[0]["AppealId"]!=null && ds.Tables[0].Rows[0]["AppealId"].ToString()!="")
				{
					model.AppealId=int.Parse(ds.Tables[0].Rows[0]["AppealId"].ToString());
				}
				return model;
			}
			else
			{
				return null;
			}
		}

		/// <summary>
		/// 获得数据列表
		/// </summary>
		public DataSet GetList(string strWhere)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select Id,Name,Sex,Age,Birthday,Nationality,Family,FamilyInfo,FamilyIncomeFrom,FamilyIncome,House,Assets,Cost,CostInfo,AcceptHelpInfo,Honour,StopSchoolingInfo,IsLiveSchool,NeedLiveMoney,Remark,Remark_V,DistrictId,Address,PostalAddress,Demand,Teacher,Principal,School,Grade_Class,PhotoList,InsTime,GoTime,IsDelete,InsertVolunteerId,VolunteerIdStr,AppealId ");
			strSql.Append(" FROM Interview ");
			if(strWhere.Trim()!="")
			{
				strSql.Append(" where "+strWhere);
			}
			return DbHelperSQL.Query(strSql.ToString());
		}

		/// <summary>
		/// 获得前几行数据
		/// </summary>
		public DataSet GetList(int Top,string strWhere,string filedOrder)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select ");
			if(Top>0)
			{
				strSql.Append(" top "+Top.ToString());
			}
			strSql.Append(" Id,Name,Sex,Age,Birthday,Nationality,Family,FamilyInfo,FamilyIncomeFrom,FamilyIncome,House,Assets,Cost,CostInfo,AcceptHelpInfo,Honour,StopSchoolingInfo,IsLiveSchool,NeedLiveMoney,Remark,Remark_V,DistrictId,Address,PostalAddress,Demand,Teacher,Principal,School,Grade_Class,PhotoList,InsTime,GoTime,IsDelete,InsertVolunteerId,VolunteerIdStr,AppealId ");
			strSql.Append(" FROM Interview ");
			if(strWhere.Trim()!="")
			{
				strSql.Append(" where "+strWhere);
			}
			strSql.Append(" order by " + filedOrder);
			return DbHelperSQL.Query(strSql.ToString());
		}

		/// <summary>
		/// 获取记录总数
		/// </summary>
		public int GetRecordCount(string strWhere)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("select count(1) FROM Interview ");
			if(strWhere.Trim()!="")
			{
				strSql.Append(" where "+strWhere);
			}
			object obj = DbHelperSQL.GetSingle(strSql.ToString());
			if (obj == null)
			{
				return 0;
			}
			else
			{
				return Convert.ToInt32(obj);
			}
		}
		/// <summary>
		/// 分页获取数据列表
		/// </summary>
		public DataSet GetListByPage(string strWhere, string orderby, int startIndex, int endIndex)
		{
			StringBuilder strSql=new StringBuilder();
			strSql.Append("SELECT * FROM ( ");
			strSql.Append(" SELECT ROW_NUMBER() OVER (");
			if (!string.IsNullOrEmpty(orderby.Trim()))
			{
				strSql.Append("order by T." + orderby );
			}
			else
			{
				strSql.Append("order by T.Id desc");
			}
			strSql.Append(")AS Row, T.*  from Interview T ");
			if (!string.IsNullOrEmpty(strWhere.Trim()))
			{
				strSql.Append(" WHERE " + strWhere);
			}
			strSql.Append(" ) TT");
			strSql.AppendFormat(" WHERE TT.Row between {0} and {1}", startIndex, endIndex);
			return DbHelperSQL.Query(strSql.ToString());
		}

		/*
		/// <summary>
		/// 分页获取数据列表
		/// </summary>
		public DataSet GetList(int PageSize,int PageIndex,string strWhere)
		{
			SqlParameter[] parameters = {
					new SqlParameter("@tblName", SqlDbType.VarChar, 255),
					new SqlParameter("@fldName", SqlDbType.VarChar, 255),
					new SqlParameter("@PageSize", SqlDbType.Int),
					new SqlParameter("@PageIndex", SqlDbType.Int),
					new SqlParameter("@IsReCount", SqlDbType.Bit),
					new SqlParameter("@OrderType", SqlDbType.Bit),
					new SqlParameter("@strWhere", SqlDbType.VarChar,1000),
					};
			parameters[0].Value = "Interview";
			parameters[1].Value = "Id";
			parameters[2].Value = PageSize;
			parameters[3].Value = PageIndex;
			parameters[4].Value = 0;
			parameters[5].Value = 0;
			parameters[6].Value = strWhere;	
			return DbHelperSQL.RunProcedure("UP_GetRecordByPage",parameters,"ds");
		}*/

		#endregion  Method
	}
}

